﻿#ifndef SEARCHTABLE_H
#define SEARCHTABLE_H
#include "SerialPort.h"

class SearchTable {
public:
	SearchTable(MainWindow& mw, std::shared_ptr<SerialPort> sp);

	void sendStartSearchTable();
	void sendStopSearchTable();
	void sendQueryNodeInfo();
	void sendQueryNodeInfoAux();

	void handleStartSearchTableResult(const QByteArray& relayMessage);
	void handleStopSearchTableResult(const QByteArray& relayMessage);
	void handleSlaveNodeReport(const QByteArray& relayMessage);
	void handleQueryNodeInfoResult(const QByteArray& relayMessage);
private:
	// 启动搜表
	std::vector<int> startSearchTable;
	// 停止搜表
	std::vector<int> stopSearchTable;
	// 查询从结点信息
	std::vector<int> queryNodeInfo;
	// 查询到从节点信息的数量
	int hasSearchedNodeInfoCnt = 0;

	MainWindow& mainWindow;

	std::shared_ptr<SerialPort> serialPort;
};

#endif
